#include<string.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/socket.h>
#include<sys/select.h>
#include<netinet/in.h>
#include<arpa/inet.h>

int main(){
  int sockfd= socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  if(sockfd<0){
    perror("socket");
    return 0;
  }
  struct sockaddr_in cliaddr;
  cliaddr.sin_family=AF_INET;
  cliaddr.sin_port=htons(2927);
  cliaddr.sin_addr.s_addr=inet_addr("10.0.8.6");
    int ret =connect(sockfd,(struct sockaddr*)&cliaddr,sizeof(cliaddr));
    if(ret<0){
  perror("connect");
  return 0;
    }
  while(1){
    char buf[1024]={0};
    strcpy(buf,"i am client");
    send(sockfd,buf,strlen(buf),0);
    memset(buf,'\0',sizeof(buf));
    recv(sockfd,buf,sizeof(buf)-1,0);
    printf("%s\n",buf);
    sleep(1);
  }
  close(sockfd);
  return 0;
}
